package com.example.Service;

import com.example.Dao.CommentDao;
import com.example.pojo.Comment;
import com.example.utils.ConnUtils;
import com.example.pojo.News;

import java.util.List;

public class CommentService {
    CommentDao commentDao=new CommentDao();

    //获取总行数
    public int getTotal(){
        return commentDao.getTotal();
    }
    //管理员角度
    public List<Comment> getAllComment(int currentPage, int pageSize){
        List<Comment> list=commentDao.getALlComment(currentPage,pageSize);
        return list;
    }

    //看评论
    public Comment getCommentInfo(int comId){
        Comment n=commentDao.getCommentInfo(comId);
        return n;
    }
    //添加新闻
    public int addComment(Comment comment){
        return commentDao.addComment(comment);
    }
    //删除评论
    public int deleteCommentById(int comId){
        int n=commentDao.deleteCommentById(comId);
        return n;
    }
    //批量删除
    public  int deleteBatchComment(List<Integer> ids){
        return commentDao.deleteBatchComment(ids);
    }

    public List<Comment> getCommentsByNewsId(int newsId){
        return commentDao.getCommentsByNewsId(newsId);
    }
    // 评论点赞
    public boolean incrementCommentLikes(int comId) {
        int result = commentDao.incrementCommentLikes(comId);
        return result > 0;
    }

    // 评论取消点赞
    public boolean decrementCommentLikes(int comId) {
        int result = commentDao.decrementCommentLikes(comId);
        return result > 0;
    }

    // 获取评论点赞数
    public int getCommentLikes(int comId) {
        return commentDao.getCommentLikes(comId);
    }
}
